package com.viu.technology.dto;

public class Result<T> {

    private String code;
    private String msg;
    private T data;


    public Result() {

    }

    public Result(ResultCode resultCode, T data) {
        this.code = resultCode.getCode();
        this.msg = resultCode.getMsg();
        this.data = data;
    }

    public Result(ResultCode resultCode) {
        this.code = resultCode.getCode();
        this.msg = resultCode.getMsg();
    }

    public static Result success() {
        return new Result(ResultCode.SUCCESS);
    }
    public static Result success(Object data) {
        return new Result(ResultCode.SUCCESS, data);
    }
    public static Result fail(ResultCode resultCode,String msg){return new Result(resultCode, msg);}
    public static Result fail(ResultCode resultCode){return new Result(resultCode);}



    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }


    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
